<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8" />

    <title>供应商 - 档案</title>

<!--    <%&#45;&#45;<link rel="stylesheet" href="/static/layer/css/layui.css" media="all">&#45;&#45;%>-->
    <link rel="stylesheet" href="/static/ace/components/_mod/jquery-ui/jquery-ui.css"/>
<!--    <%&#45;&#45;<link rel="stylesheet" href="/static/statistics/css/bootstrap-datetimepicker.min.css">&#45;&#45;%>-->
    <link rel="stylesheet"
          href="/static/ace/components/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css"/>
    <link rel="stylesheet" href="/static/ace/components/_mod/jqgrid/ui.jqgrid.css"/>
    <script src="/static/statistics/js/bootstrap-datetimepicker.min.js"></script>
<!--    <%&#45;&#45;<script src="/static/statistics/js/bootstrap-datetimepicker.fr.js"></script>&#45;&#45;%>-->
    <script src="/static/statistics/js/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="/static/statistics/js/vue.js"></script>
    <script src="/static/countjs/regularYz.js"></script>
    <style type="text/css">
        .customBtn {
            line-height: 20px;
            margin-bottom: 3px;
        }

        .btnLine {
            margin-left: 1px;
            margin-top: 8px;
            margin-bottom: 2px;
        }

        @-webkit-keyframes bouncedelay {
            0%, 80%, 100% {
                -webkit-transform: scale(0.0)
            }
            40% {
                -webkit-transform: scale(1.0)
            }
        }

        @keyframes bouncedelay {
            0%, 80%, 100% {
                transform: scale(0.0);
                -webkit-transform: scale(0.0);
            }
            40% {
                transform: scale(1.0);
                -webkit-transform: scale(1.0);
            }
        }

        .autocomplete-suggestions {
            border: 1px solid #999;
            background: #FFF;
            overflow: auto;
        }

        .autocomplete-suggestion {
            padding: 2px 5px;
            white-space: nowrap;
            overflow: hidden;
        }

        .autocomplete-selected {
            background: #F0F0F0;
        }

        .autocomplete-suggestions strong {
            font-weight: normal;
            color: #3399FF;
        }

        @-moz-document url-prefix() {
            fieldset {
                display: table-cell;
            }
        }

        .ui-jqgrid-sortable {
            text-align: center;
        }
    </style>
</head>
<body>
<div class="row" id="appAlert">
    <div class="row btnLine">
        <div class="button-len col-sm-12">
            <div style="width: 100%; margin-bottom: 10px;">
                <button class="btn btn-white btn-sm btn-purple customBtn"  v-on:click="addSupplier">
                    <i class="ace-icon fa fa-plus-circle purple"></i> 新增
                </button>
                <button class="btn btn-white btn-info btn-sm customBtn" id="editSupplier">
                    <i class="ace-icon fa fa-pencil blue"></i> 修改
                </button>
                <button class="btn btn-white btn-info btn-sm customBtn" id="deleteSupplier">
                    <i class="ace-icon fa fa-key red"></i> 删除
                </button>
                <button class="btn btn-white btn-info btn-sm customBtn" id="editState">
                    <i class="ace-icon fa fa-key red"></i> 修改状态
                </button>
            </div>
            <input class="input-sm" type="text" id="keyword" style="margin-left: 0px;" value=""
                   placeholder="关键字" />
            <button class="btn btn-sm btn-white btn-info search-len customBtn"
                    onclick="searchShop()">
                <i class="ace-icon fa fa-search orange"></i>搜索
            </button>
        </div>
    </div>
    <!-- 内容数据开始 -->
    <div class="col-xs-12">
        <table id="grid-table"></table>

        <div id="grid-pager"></div>

    </div>

    <!-- 内容数据结束 -->

    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="">
            <div class="modal-content">
                <div class="modal-header" style="font-size: 20px; margin-bottom: -15px;">
                    <h4 class="modal-title" id="myModalLabel">
                        供应商管理 - <span id="alertTitle">新增</span>
                        <small id="smallTitle" class="hide" style="color: red; float: right; margin-top: 10px;">哈哈哈</small>

                    </h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <button class="btn btn-white btn-info btn-sm customBtn btn-xs" type="button" v-on:click="tableShow">基础信息</button>
                        <button class="btn btn-white btn-info btn-sm customBtn btn-xs" type="button" v-on:click="businessLicenseShow">营业执照</button>
                        <button class="btn btn-white btn-info btn-sm customBtn btn-xs" type="button" v-on:click="licenceShow">许可证</button>
                    </div>

                    <div class="row" id="tableDiv">
                        <form >
                            <table class="table">
                                <tbody>
                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        编码
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="id" placeholder="新增编码自动生产" readonly="readonly" style="width: 150px; height: 20px;" />
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        名称
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="supplierName" name="supplierName" placeholder="名称" style="width: 150px; height: 20px;"
                                               onblur="" onfocus="" />
                                        <span id="supplierNameMsg" style="color: red"></span>
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        联系人
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="contactName" placeholder="联系人" style="width: 150px; height: 20px;"
                                               onblur="" onfocus="" />
                                        <span id="contactNameMsg" style="color: red"></span>
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        助记码
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="helpCode" placeholder="助记码" style="width: 150px; height: 20px;" />
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        <!--                                            <%&#45;&#45;手机号码&#45;&#45;%>-->
                                    </td>
                                    <td>
                                        <!--                                            <%&#45;&#45;<input type="text" class="form-control" id="phone" placeholder="手机号码" style="width: 150px; height: 20px;"&#45;&#45;%>-->
                                        <!--                                            <%&#45;&#45;onblur="" onfocus="">&#45;&#45;%>-->
                                        <!--                                            <%&#45;&#45;<span id="phoneMsg" style="color: red"></span>&#45;&#45;%>-->
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        电话
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="mobile" placeholder="电话" style="width: 150px; height: 20px;"
                                               onblur="" onfocus="" />
                                        <span id="mobileMsg" style="color: red"></span>
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        地址
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="address" placeholder="地址" style="width: 150px; height: 20px;"
                                               onblur="" onfocus="" />
                                        <span id="addressMsg" style="color: red"></span>
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        传真
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="fax" placeholder="传真" style="width: 150px; height: 20px;"
                                               onblur="" onfocus="" />
                                        <span id="faxMsg" style="color: red"></span>
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        邮编
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="zipCode" placeholder="邮编" style="width: 150px; height: 20px;"
                                               onblur="verify(this.value, this.id,'zipCode')" onfocus="" />
                                        <span id="zipCodeMsg" style="color: red"></span>
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        电子邮件
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="email" placeholder="电子邮件" style="width: 150px; height: 20px;"
                                               onblur="" onfocus="" />
                                        <span id="emailMsg" style="color: red"></span>
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        经营方式
                                    </td>
                                    <td>
                                        <select class="form-control" id="operatorWay" style="width: 150px; height: 20px;">
                                            <option selected="selected" value="A">购销</option>
                                            <option value="C">联营</option>
                                            <option value="F">扣率代销</option>
                                        </select>
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        业务员
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="salesMan" placeholder="业务员" style="width: 150px; height: 20px;"
                                               onblur="" onfocus="focusVerify(this.id)" />
                                        <span id="salesManMsg" style="color: red"></span>
                                    </td>
                                </tr>


                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        区域
                                    </td>
                                    <td>
                                        <select class="form-control" id="zoneCode" style="width: 150px; height: 20px;">
                                            <option selected="selected" value="01">东北</option>
                                            <option value="02">西南</option>
                                            <option value="03">东南</option>
                                            <option value="04">西北</option>
                                            <option value="05">。。。。。</option>
                                            <option value="08">汇源果汁</option>
                                            <option value="QY">其它区域</option>

                                        </select>
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        冻结账款
                                    </td>
                                    <td>
                                        <select class="form-control" id="freezeAccounts" style="width: 150px; height: 20px;">
                                            <option selected="selected" value="0">正常</option>
                                            <option value="1">冻结</option>
                                        </select>
                                    </td>
                                </tr>


                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        结算方式
                                    </td>
                                    <td>
                                        <select class="form-control" id="settlementWay" style="width: 150px; height: 20px;">
                                            <option selected="selected" value="0">临时指定</option>
                                            <option value="1">货到付款</option>
                                            <option value="2">指定账期</option>
                                            <option value="3">指定日期</option>
                                        </select>
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        冻结业务
                                    </td>
                                    <td>
                                        <select class="form-control" id="freezeBusiness" style="width: 150px; height: 20px;">
                                            <option selected="selected" value="0">正常</option>
                                            <option value="1">冻结</option>
                                        </select>
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        送货周期
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="deliverCycle" value="7" placeholder="7" style="width: 150px; height: 20px;"
                                               onblur="verify(this.value, this.id,'deliverCycle')" onfocus="focusVerify(this.id)" />
                                        <span id="deliverCycleMsg" style="color: red"></span>
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        开户行
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="bankOfDeposit" placeholder="开户行" style="width: 150px; height: 20px;"
                                               onblur="verify(this.value, this.id,'bankOfDeposit')" onfocus="focusVerify(this.id)" />
                                        <span id="bankOfDepositMsg" style="color: red"></span>
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        结账周期
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="settlementCycle" value="30" readonly="readonly" placeholder="30" style="width: 150px; height: 20px;" />
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        帐号
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="account" placeholder="帐号" style="width: 150px; height: 20px;"
                                               onblur="verify(this.value, this.id,'account')" onfocus="focusVerify(this.id)" />
                                        <span id="accountMsg" style="color: red"></span>
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        月结账日期
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="monthSettlementDay" value="30" readonly="readonly" placeholder="30" style="width: 150px; height: 20px;" />
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        营业执照号
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="businessLicenseNo" placeholder="营业执照号" style="width: 150px; height: 20px;"
                                               onblur="verify(this.value, this.id,'businessLicenseNo')" onfocus="focusVerify(this.id)" />
                                        <span id="businessLicenseNoMsg" style="color: red"></span>
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        备注
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="remark" placeholder="" style="width: 150px; height: 20px;"
                                               onblur="verify(this.value, this.id,'remark')" onfocus="focusVerify(this.id)" />
                                        <span id="remarkMsg" style="color: red"></span>
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        注册类型
                                    </td>
                                    <td>
                                        <select class="form-control" id="registerWay" style="width: 150px; height: 20px;">
                                            <option selected="selected" value="1">国有</option>
                                            <option value="2">民营</option>
                                            <option value="3">合资</option>
                                            <option value="4">外资</option>
                                            <option value="5">个体</option>
                                        </select>
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        采购默认价
                                    </td>
                                    <td>
                                        <select class="form-control" style="width: 150px; height: 20px;">
                                            <option selected="selected" value="0">进货价</option>
                                            <option value="2">零售价</option>
                                            <option value="6">约定价格</option>
                                            <option value="4">最近进价</option>
                                        </select>
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        税务登记号
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="taxRegistrationNo" placeholder="请输入名称" style="width: 150px; height: 20px;"
                                               onblur="verify(this.value, this.id,'taxRegistrationNo')" onfocus="focusVerify(this.id)" />
                                        <span id="taxRegistrationNoMsg" style="color: red"></span>
                                    </td>
                                </tr>

                                <tr>
                                    <td style="width: 86px; text-align: right">
                                        所属机构
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="orgCode" placeholder="请输入名称" style="width: 150px; height: 20px;"
                                               onblur="verify(this.value, this.id,'orgCode')" onfocus="focusVerify(this.id)" />
                                        <span id="orgCodeMsg" style="color: red"></span>
                                    </td>
                                    <td style="width: 86px; text-align: right">
                                        户名
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" id="userName" placeholder="请输入名称" style="width: 150px; height: 20px;"
                                               onblur="verify(this.value, this.id,'userName')" onfocus="focusVerify(this.id)" />
                                        <span id="userNameMsg" style="color: red"></span>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </form>
                    </div>

                    <div class="row hide" id="businessLicenseDiv">
                        <div style="margin:10px auto;border:1px solid #000;width:320px;height:240px;">
                            <img id="showImageInfoImg" style="width:320px;height:240px;" src="" alt="..." class="img-thumbnail" />
                        </div>
                        <p style="font-size: 12px; text-align: center;">图片显示(图片窗口大小为320*240，上传图片最佳宽高比例为4：3,图片大小限制在300K以内)</p>
                        <div style="margin-top: 10px; text-align: center;">
                            <input type="file" name="file" id="image_file_input" class="inputfile hide"/>
                            <label for="image_file_input"><i class="ace-icon fa fa-folder-open"></i> 请选择图片</label>
                        </div>
                        <div style="margin-top: 10px; text-align: center;">
                            <button class="btn btn-white btn-info btn-sm customBtn btn-xs" type="button" v-on:click="submitImg">上传</button>
                            <button class="btn btn-white btn-info btn-sm customBtn btn-xs" type="button" v-on:click="">删除</button>
                        </div>
                    </div>

                    <div class="row hide" id="licenceDiv">
                        <div style="margin:10px auto;border:1px solid #000;width:320px;height:240px;">
                            <img id="showImageInfoImg1" style="width:320px;height:240px;" src="" alt="..." class="img-thumbnail" />
                        </div>
                        <p style="font-size: 12px; text-align: center;">图片显示(图片窗口大小为320*240，上传图片最佳宽高比例为4：3,图片大小限制在300K以内)</p>
                        <div style="margin-top: 10px; text-align: center;">
                            <input type="file" name="file" id="image_file_input1" class="inputfile hide"/>
                            <label for="image_file_input1"><i class="ace-icon fa fa-folder-open"></i> 请选择图片</label>
                        </div>
                        <div style="margin-top: 10px; text-align: center;">
                            <button class="btn btn-white btn-info btn-sm customBtn btn-xs" type="button" v-on:click="submitImg1">上传</button>
                            <button class="btn btn-white btn-info btn-sm customBtn btn-xs" type="button" v-on:click="">删除</button>
                        </div>
                    </div>


                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default btn-xs" data-dismiss="modal" v-on:click="close">关闭</button>
                    <button type="button" class="btn btn-primary btn-xs" v-on:click="saveSupplier">提交更改</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <!-- 修改状态 模态框（Modal） -->
    <div id="container">
        <div id="example1" class="modal fade">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <a class="close" data-dismiss="modal">×</a>
                        <h3>修改状态</h3>
                    </div>
                    <div class="modal-body">
                        <label style="">状态</label>
                        <select class="input-sm" id="state1">
                            <option selected="selected" value="1">新建</option>
                            <option value="2">正常</option>
                            <option value="3">业务冻结</option>
                            <option value="4">财务冻结</option>
                            <option value="5">停用</option>
                        </select>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default btn-xs" data-dismiss="modal" v-on:click="close">关闭</button>
                        <button type="button" class="btn btn-primary btn-xs" id="saveState">提交更改</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<input type="text" name="fileStr" id="fileStr" style="display: none"/>
<input type="text" name="fileType" id="fileType" style="display:none"/>

<input type="text" name="fileStr1" id="fileStr1" style="display: none"/>
<input type="text" name="fileType1" id="fileType1" style="display:none"/>

<!-- page specific plugin scripts -->
<script type="text/javascript" src="/static/statistics/js/jquery.mockjax.js"></script>
<script type="text/javascript" src="/static/statistics/js/jquery.autocomplete.js"></script>
<script type="text/javascript">

    var grid_selector = "#grid-table";
    var pager_selector = "#grid-pager";

    var laypage = layui.laypage,
        layer = layui.layer
    laydate = layui.laydate;

    var scripts = [null, "/static/ace/components/bootstrap-datepicker/dist/js/bootstrap-datepicker.js", "/static/ace/components/jqGrid/js/jquery.jqGrid.js", "/static/ace/components/jqGrid/js/i18n/grid.locale-cn.js", "/static/layer/layer.js", null]
    $('.page-content-area').ace_ajax('loadScripts', scripts, function () {
        jQuery(function ($) {

            var parent_column = $(grid_selector).closest('[class*="col-"]');
            //resize to fit page size
            $(window).on('resize.jqGrid', function () {
                $(grid_selector).jqGrid('setGridWidth', parent_column.width());
            })

            //resize on sidebar collapse/expand
            $(document).on('settings.ace.jqGrid', function (ev, event_name, collapsed) {
                if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') {
                    //setTimeout is for webkit only to give time for DOM changes and then redraw!!!
                    setTimeout(function () {
                        $(grid_selector).jqGrid('setGridWidth', parent_column.width());
                    }, 20);
                }
            })

            jQuery(grid_selector).jqGrid({
                //direction: "rtl",

                //subgrid options
                subGrid: false,
                url: "/ktPurchase/getSupplierListByPage",
                //data: grid_data,
                datatype: "json",
                mtype: 'POST',
                height: 350,
                colNames: ['编码', '名称', '助记码', '联系人', '经营方式', '送货周期', '结账周期', '月结账日期', '结算方式', '业务员编码', '业务员名称', '电话', '区域编码', '区域名称', '机构编码', '机构名称', '状态'],
                colModel: [
                    {
                        name: 'id',
                        index: 'id',
                        width: 60,
                        editable: true,
                        formatter: cLink
                    },
                    {
                        name: 'supplierName',
                        index: 'supplierName',
                        width: 90,
                        editable: true,
                        sortable: false,
                        editrules: {required: true}
                    },
                    {
                        name: 'helpCode',
                        index: 'helpCode',
                        width: 90,
                        editable: true,
                        sortable: false,
                        editrules: {
                            required: true,
                            //                            custom: true   //
                        }
                    },
                    {name: 'contactName', index: 'contactName', width: 70, editable: false, sortable: false},
                    {
                        name: 'operatorWay',
                        index: 'operatorWay',
                        width: 90,
                        editable: true,
                        sortable: false,
                        //                    edittype: 'select',
                        editrules: {required: true}
                    },
                    {
                        name: 'deliverCycle',
                        index: 'deliverCycle',
                        width: 90,
                        editable: true,
                        sortable: false,
                        //                    edittype: 'select',
                        //                    editoptions: {value: " :不选择;毕节:毕节;六盘水:六盘水;安顺:安顺;贵安:贵安;贵阳:贵阳;遵义:遵义;铜仁:铜仁"}
                    },
                    {name: 'settlementCycle', index: 'settlementCycle', width: 90, editable: true, sortable: false},
                    {
                        name: 'monthSettlementDay',
                        index: 'monthSettlementDay',
                        width: 130,
                        editable: true,
                        sortable: false
                    },
                    {
                        name: 'settlementWay',
                        index: 'settlementWay',
                        width: 100,
                        editable: true,
                        sortable: false,
                        //edittype: 'select',
                        // editoptions: {dataUrl: '/checking/getQuXianNameInfoToSelected'}
                    },
                    {
                        name: 'salesMan',
                        index: 'salesMan',
                        width: 100,
                        editable: true,
                        sortable: false,
                        //edittype: 'select',
                        // editoptions: {dataUrl: '/checking/getQuXianNameInfoToSelected'}
                    },
                    {
                        name: 'salesName',
                        index: 'salesNaem',
                        width: 100,
                        editable: true,
                        sortable: false,
                        //edittype: 'select',
                        //editoptions: {dataUrl: '/checking/getEmpInfoToSelected'}
                    },
                    {
                        name: 'mobile', index: 'mobile', width: 80, editable: true, sortable: false,
                        //                        custom_func: isPhone
                    },
                    {
                        name: 'zoneCode',
                        index: 'zoneCode',
                        width: 90,
                        editable: true,
                        sortable: false,
                        //                    edittype: 'select',
                        //                    editoptions: {value: "0:有效;1:无效"}
                    },
                    {name: 'zoneName', index: 'zoneName', width: 150, editable: false},
                    {name: 'orgCode', index: 'orgCode', width: 150, editable: false},
                    {name: 'orgName', index: 'orgName', width: 150, editable: false},
                    {
                        name: 'state',
                        index: 'state',
                        width: 90,
                        editable: true,
                        sortable: false,
                        edittype: 'select',
                        formatter: function (v, x, r) {
                            var state = r['state'];
                            if (state == '1') {
                                return '新建'
                            }
                            if (state == '2') {
                                return '正常'
                            }
                            if (state == '3') {
                                return '业务冻结'
                            }
                            if (state == '4') {
                                return '财务冻结'
                            }
                            if (state == '5') {
                                return '停用'
                            }
                            return '-'
                        }
                        //                        editoptions: {value: "0:有效;1:无效"}
                    },

                ],

                rownumbers: true, //自动行数
                //                        width:"1000",
                autowidth: true,  //宽度自适应
                //                        height:"100%",   //高度自适应
                viewrecords: true,
                rowNum: 10,//一页显示多少条
                rowList: [10, 20, 30],//可供用户选择一页显示多少条
                pager: pager_selector,//表格页脚的占位符(一般是div)的id
                sortname: 'gmtModifiedStr',//初始化的时候排序的字段
                sortorder: "desc",//排序方式,可选desc,asc
                //                mtype : "post",//向后台请求数据的ajax的类型。可选post,get
                altRows: true,
                //                toppager: true,
                multiselect: false,
                //multikey: "ctrlKey",
                multiboxonly: false,

                loadComplete: function () {
                    var table = this;
                    setTimeout(function () {
                        styleCheckbox(table);

                        updateActionIcons(table);
                        updatePagerIcons(table);
                        enableTooltips(table);
                    }, 0);
                },

                editurl: "/ktPurchase/saveSupplier",//nothing is saved
                caption: "档案信息",
                jsonReader: {
                    root: "recordList",
                    page: "currentPage",
                    total: "pageCount",
                    records: "recordCount"
                }

                //,autowidth: true,


                /**
                 ,
                 grouping:true,
                 groupingView : {
                     groupField : ['name'],
                     groupDataSorted : true,
                     plusicon : 'fa fa-chevron-down bigger-110',
                     minusicon : 'fa fa-chevron-up bigger-110'
                },
                 caption: "Grouping"
                 */

            });

            $(window).triggerHandler('resize.jqGrid');//trigger window resize to make the grid get the correct size


            function cLink(cellvalue, options, rowObject) {
               // console.log(rowObject)
                var id = rowObject.id;
                /*<![CDATA[*/
                return '<a href="/sys/user/home#page/franchiseePrementSupplierSuppliercoommdity&id=' + id + '" onclick="">' + id + '</a>';
                /*]]>*/
            }


            /**
             * 修改某条信息
             */
            $("#editSupplier").click(function () {
                var id = $(grid_selector).jqGrid('getGridParam', 'selrow');
                if (!id) {
                    layer.msg("提示：请选择一条信息");
                    return;
                }

                var rowData = $(grid_selector).jqGrid('getRowData', id);
                console.log(rowData)
                /*<![CDATA[*/
                // console.log(rowData.id.split('>')[1].split('<')[0]);
                // rowData.id = rowData.id.split('>')[1].split('<')[0];
                /*]]>*/
                //                layer.load(1);
                getSupplier(rowData);
                reload();

            });

            /**
             * 删除某条数据
             */
            $("#deleteSupplier").click(function () {
                var id = $(grid_selector).jqGrid('getGridParam', 'selrow');

                if (!id) {
                    layer.msg("提示：请选择一条信息");
                    return;
                }
                //询问框
                layer.confirm('将会把这条供应商数据删除', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    var rowData = $(grid_selector).jqGrid('getRowData', id);
                    /*<![CDATA[*/
                    // rowData.id = rowData.id.split('>')[1].split('<')[0];
                    /*]]>*/
                    queryModel.id = rowData.id;
                    layer.load(1);
                    $.ajax({
                        url: '/ktPurchase/deleteSupplier',
                        type: 'post',
                        data: queryModel,
                        dataType: 'json',
                        success: function (data) {
                            layer.closeAll('loading');
                            if (data.success) {
                                layer.msg('删除成功', {icon: 1});

                            } else {
                                layer.msg(data.message);
                            }
                            reload();

                        },
                        error: function (error) {
                            layer.closeAll('loading');
                            $.jgrid.info_dialog("提示：", "服务器异常，稍后再试");
                        }

                    })

                }, function () {

                })
            });
        });
    });
</script>
<script src="/static/layer/layui.all.js"></script>
<script type="text/javascript">

    /**
     * 搜索店铺
     */
    function searchShop() {
        var keyword = $("#keyword").val();
//        var phone = $("#phone").val();
        //var parentDepartmentkey = $("#id_parentDepartmentkey_name").val();

        var filters = {
            "rules": [{
                "field": "keyword",
                "data": keyword
            }]
        };
        jQuery("#grid-table").jqGrid('setGridParam', {
            postData: {
                "filters": JSON.stringify(filters) //"{'rules' : [{'field' : 'shopName','data' : "+shopName+"},{'field' : 'state','data' : "+state+"}]}"
            }
        }).trigger("reloadGrid");
    }

    $("#id").show();
    var img64 = "";
    $("#showImageInfoImg").attr("src", img64);
    $("#showImageInfoImg1").attr("src", img64);

    var laypage = layui.laypage,
        layer = layui.layer
    laydate = layui.laydate;

    var queryModel = {
        //分页参数
        page: '1',
        rows: '10',
        //图片参数
//        fileStr: '',
//        fileType: '',
//        fileStart: '',
//        supplierName: '',
//        state: '',
//        createTime: '',
//        createUser: '',
//        modifyTime: '',
//        modifyUser: '',
//        contactName: '',
//        mobile: '',
//        helpCode: '',
//        phone: '',
//        fax: '',
//        email: '',
//        zipCode: '',
//        operatorWay: '',
//        salesMan: '',
//        zoneCode: '',
//        settlementWay: '',
//        freezeAccounts: '',
//        freezeBusiness: '',
//        deliverCycle: '',
//        settlementCycle: '30',
//        monthSettlementDay: '30',
//        remark: '',
//        registerWay: '',
//        orgCode: '',
//        bankOfDeposit: '',
//        account: '',
//        businessLicenseNo: '',
//        taxRegistrationNo: '',
//        userName: '',
//        businessLicenseImage: '',
//        licenseImage: '',
//        defaultPurchaseWay: '',
//        guaranteeQuota: '',
//        discountRate: ''
    }

    var app = new Vue({
        el: '#appAlert',
        data: {
            objects: [],
        },
        methods: {
            tableShow: function () {
                $("#alertTitle").html("新增")
                $("#businessLicenseDiv").addClass("hide")
                $("#licenceDiv").addClass("hide")
                $("#smallTitle").addClass("hide")
                $("#tableDiv").removeClass("hide")
            },
            businessLicenseShow: function () {
                $("#alertTitle").html("营业执照")
                $("#tableDiv").addClass("hide")
                $("#licenceDiv").addClass("hide")
                $("#smallTitle").addClass("hide")
                $("#businessLicenseDiv").removeClass("hide")

            },
            licenceShow: function () {
                $("#alertTitle").html("许可证")
                $("#tableDiv").addClass("hide")
                $("#smallTitle").addClass("hide")
                $("#businessLicenseDiv").addClass("hide")
                $("#licenceDiv").removeClass("hide")
            },
            saveSupplier: function () {
                $("#alertTitle").html("新增")
                $("#businessLicenseDiv").addClass("hide")
                $("#licenceDiv").addClass("hide")
                $("#tableDiv").removeClass("hide")
                $("#smallTitle").addClass("hide")
                $("#showImageInfoImg").attr("src",img64)
                $("#showImageInfoImg1").attr("src",img64)
                queryObjects()
            },
            addSupplier: function () {
                $("#alertTitle").html("新增")
                $("#businessLicenseDiv").addClass("hide")
                $("#licenceDiv").addClass("hide")
                $("#tableDiv").removeClass("hide")
                $("#smallTitle").addClass("hide")
                $("#smallTitle").addClass("hide")
                $("#showImageInfoImg").attr("src",img64)
                $("#showImageInfoImg1").attr("src",img64)
                var rowData = {}
                editShop(rowData)
            },
            submitImg: function () {
                submitImg("1", true)
            },
            submitImg1: function () {
                submitImg("2", true)
            },
            close: function () {
                $("#alertTitle").html("新增")
                $("#businessLicenseDiv").addClass("hide")
                $("#licenceDiv").addClass("hide")
                $("#tableDiv").removeClass("hide")
                $("#smallTitle").addClass("hide")
                $("#showImageInfoImg").attr("src",img64)
                $("#showImageInfoImg1").attr("src",img64)
            }
        }
    });


    var submitImg = function (fileStart, fruset) {
        var id = $("#id").val();

        var fileType = "";
        var imageFile = "";
        var fileStr = "";
        if (fileStart == '1'){
            fileStr = $("#fileStr").val();
            fileType = $("#fileType").val();
            imageFile = $("#image_file_input")[0].files[0];
        }else if (fileStart == '2'){
            fileStr = $("#fileStr1").val();
            fileType = $("#fileType1").val();
            imageFile = $("#image_file_input1")[0].files[0];
        }
        if (fileType == "") {
            $("#smallTitle").html("提示：请选择上传图片");
            $("#smallTitle").removeClass("hide");
            return;
        }
        queryModel.fruset = fruset;
//        if (fruset){
//            if (!id){
//                $("#smallTitle").html("提示：没有基础信息绑定");
//                $("#smallTitle").removeClass("hide");
//                return;
//            }
//        }

        if (imageFile.size > 524288) {
            $("#smallTitle").html("封面图片不得大于512KB");
            $("#smallTitle").removeClass("hide");
            return
        }
        var index = fileStr.indexOf("base64,");

        if (index > 0) {
            fileStr = fileStr.substring(index + 7);
            var fileType = $("#fileType").val();
            fileType = fileType.substring(6);
            if (fileStart == '1'){
                $("#fileStr").val(fileStr);
                $("#fileType").val(fileType);
            }else if (fileStart == '2'){
                $("#fileStr1").val(fileStr);
                $("#fileType1").val(fileType);
            }
        }
        if (fileStart == '1'){
            queryModel.fileStr = $("#fileStr").val();
            queryModel.fileType = $("#fileType").val();
        }else if (fileStart == '2'){
            queryModel.fileStr = $("#fileStr").val();
            queryModel.fileType = $("#fileType").val();
        }
        queryModel.fileStart = fileStart;

//        console.log(queryModel);
        //return
//        formData["text"] = $('#summernote').summernote("code");
//        formData["cloudId"] = $("#cloudlingId").val();
//        formData["firstUserId"] = $("#firstUserId").val();
//        formData["endUserId"] = $("#endUserId").val();
        // console.log(formData)
        //return
        layer.load(1);
        $.ajax({
            type: 'POST',
            url: '/ktPurchase/submitImg',
            data: queryModel,
            dataType: 'json',
            success: function (data) {
                layer.closeAll('loading');
                if (data.success == false){
                    $("#smallTitle").html(data.message);
                    return
                }
                $("#smallTitle").html(data.message);
                $("#smallTitle").removeClass("hide");
                var dataArray = data.data;
                if (fileStart == '1') {
                    queryModel.businessLicenseImage = dataArray;
                }else if (fileStart == '2'){
                    queryModel.licenseImage = dataArray;
                }
                console.log(queryModel)
            },
            error: function (result) {
                layer.closeAll('loading');
                $("#smallTitle").html("上传失败！");
                $("#smallTitle").removeClass("hide");
            }
        });
    }

    var getSupplier = function (rowData) {
        $("#showImageInfoImg").attr("src",img64)
        $("#showImageInfoImg1").attr("src",img64)
        var helpCode = rowData.helpCode;
        var supplierName = rowData.supplierName;
        var beginNum = rowData.beginNum;
        var filters = {
            "rules": [
                {"field": "supplierName",  "data": supplierName},
                {"field": "beginNum",  "data": beginNum},
                {"field": "helpCode",  "data": helpCode},
            ]
        };
        var supplierArrray = {
            //分页参数
            page: '1',
            rows: '10',
        };
        supplierArrray.filters = JSON.stringify(filters);
        console.log(supplierArrray)
        layer.load(1)
        $.ajax({
            url: '/ktPurchase/getSupplierListByPage',
            type: 'post',
            data: supplierArrray,
            success: function (data) {
                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }
                var dataArray = data.recordList;
                if (dataArray.length == 0){
                    layer.msg("查询没有数据")
                    return
                }
                console.log(dataArray)
                $("#alertTitle").html('修改');
                editShop(dataArray[0]);
            },
            error: function (error) {
                layer.closeAll('loading')
            }
        })
    };


    var getObjects = function () {
        console.log(queryModel)
        layer.load(1)
        $.ajax({
            url: '/ktPurchase/saveSupplier',
            type: 'post',
            data: queryModel,
            success: function (data) {
                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message)
                    return
                }

                $('#myModal').modal('hide');
                layer.msg("提示："+data.message);
                reload();
            },
            error: function (error) {
                layer.closeAll('loading')
            }
        })
    };
    var queryObjects = function () {

        var fileType = $("#fileType").val();
        if (fileType != "") {
            submitImg("1", false);
        }
        var fileType1 = $("#fileType1").val();
//        console.log(fileType1 != "")
        if (fileType1 != "") {
            submitImg("2", false);
        }

        queryModel.id = $("#id").val();
        queryModel.supplierName = $("#supplierName").val();
        queryModel.state = $("#state").val();
        queryModel.createTime = $("#createTime").val();
        queryModel.createUser = $("#createUser").val();
        queryModel.modifyTime = $("#modifyTime").val();
        queryModel.modifyUser = $("#modifyUser").val();
        queryModel.contactName = $("#contactName").val();
        queryModel.mobile = $("#mobile").val();
        queryModel.helpCode = $("#helpCode").val();
        queryModel.phone = $("#phone").val();
        queryModel.fax = $("#fax").val();
        queryModel.email = $("#email").val();
        queryModel.zipCode = $("#zipCode").val();
        queryModel.operatorWay = $("#operatorWay").val();
        queryModel.salesMan = $("#salesMan").val();
        queryModel.zoneCode = $("#zoneCode").val();
        queryModel.settlementWay = $("#settlementWay").val();
        queryModel.freezeAccounts = $("#freezeAccounts").val();
        queryModel.freezeBusiness = $("#freezeBusiness").val();
        queryModel.deliverCycle = $("#deliverCycle").val();
//        queryModel.settlementCycle = $("#settlementCycle").val();
        queryModel.monthSettlementDay = $("#monthSettlementDay").val();
        queryModel.remark = $("#remark").val();
        queryModel.registerWay = $("#registerWay").val();
        queryModel.orgCode = $("#orgCode").val();
        queryModel.bankOfDeposit = $("#bankOfDeposit").val();
        queryModel.account = $("#account").val();
        queryModel.businessLicenseNo = $("#businessLicenseNo").val();
        queryModel.taxRegistrationNo = $("#taxRegistrationNo").val();
        queryModel.userName = $("#userName").val();
//        queryModel.businessLicenseImage = businessLicenseImage;
//        queryModel.licenseImage = licenseImage;
        queryModel.defaultPurchaseWay = $("#defaultPurchaseWay").val();
        queryModel.guaranteeQuota = $("#guaranteeQuota").val();
        queryModel.discountRate = $("#discountRate").val();

//        console.log(queryModel)
        if(submitVerify(queryModel)){
            getObjects(queryModel)
        }
    }


    $('#beginTime').datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        minView: 2,
        showMeridian: 1,
        format: "yyyy-mm-dd",
//        startDate:new Date(),
    });


    $('#endTime').datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        minView: 2,
        showMeridian: 1,
        format: "yyyy-mm-dd",
//        startDate:new Date(),
    });

    /**
     * 弹窗内容
     * @param rowData
     */
    var editShop = function (rowData) {
        console.log(rowData)
        $("#id").val(rowData.id);
        $("#supplierName").val(rowData.supplierName);
        $("#state").val(rowData.state);
        $("#createTime").val(rowData.createTime);
        $("#createUser").val(rowData.createUser);
        $("#modifyTime").val(rowData.modifyTime);
        $("#modifyUser").val(rowData.modifyUser);
        $("#contactName").val(rowData.contactName);
        $("#mobile").val(rowData.mobile);
        $("#helpCode").val(rowData.helpCode);
        $("#phone").val(rowData.phone);
        $("#fax").val(rowData.fax);
        $("#email").val(rowData.email);
        $("#zipCode").val(rowData.zipCode);
        $("#operatorWay").val(rowData.operatorWay);
        $("#salesMan").val(rowData.salesMan);
        $("#zoneCode").val(rowData.zoneCode);
        $("#settlementWay").val(rowData.settlementWay);
        $("#freezeAccounts").val(rowData.freezeAccounts);
        $("#freezeBusiness").val(rowData.freezeBusiness);
        $("#deliverCycle").val(rowData.deliverCycle);
//        $("#settlementCycle").val(rowData.settlementCycle);
//        $("#monthSettlementDay").val(rowData.monthSettlementDay);
        $("#remark").val(rowData.remark);
        $("#registerWay").val(rowData.registerWay);
        $("#orgCode").val(rowData.orgCode);
        $("#bankOfDeposit").val(rowData.bankOfDeposit);
        $("#account").val(rowData.account);
        $("#businessLicenseNo").val(rowData.businessLicenseNo);
        $("#taxRegistrationNo").val(rowData.taxRegistrationNo);
        $("#userName").val(rowData.userName);
//        $("#businessLicenseImage").val(rowData.businessLicenseImage);
//        $("#licenseImage").val(rowData.licenseImage);
        $("#defaultPurchaseWay").val(rowData.defaultPurchaseWay);
        $("#guaranteeQuota").val(rowData.guaranteeQuota);
        $("#discountRate").val(rowData.discountRate);

        var businessLicenseImage = !rowData.businessLicenseImage;
        var licenseImage = !rowData.licenseImage;
        if (!businessLicenseImage) {
            console.log(rowData.businessLicenseImage)
            $("#showImageInfoImg").attr("src", 'http://clouderp.skystorechain.com:20080/'+rowData.businessLicenseImage);
        }
        if (!licenseImage) {
            console.log(rowData.licenseImage)
            $("#showImageInfoImg1").attr("src", 'http://clouderp.skystorechain.com:20080/'+rowData.licenseImage);
        }
        $('#myModal').modal('show');
    }

    var input = document.getElementById("image_file_input");
    if (typeof(FileReader) === 'undefined') {
        alert("抱歉，你的浏览器不支持 FileReader，请使用现代浏览器操作！");
        input.setAttribute('disabled', 'disabled');
    } else {
        input.addEventListener('change', readFile, false);
    }

    function readFile() {
        $("#smallTitle").addClass("hide");
        var file = this.files[0];
        if(file == undefined) {
            //layer.msg("发送内容过大，请检查图片和内容");
            $("#showImageInfoImg").attr("src",img64);
            $("#fileStr").val("");
            $("#fileType").val("");
            return;
        }
        //这里我们判断下类型如果不是图片就返回 去掉就可以上传任意文件
        if (!/image\/\w+/.test(file.type)) {
            layer.msg("请确保文件为图像类型");
            return false;
        }
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function (e) {
            $("#fileStr").val(this.result);
            //document.getElementById("fileStr").value = '<img src="'+this.result+'" alt=""/>';
            //img_area.innerHTML = '<div class="sitetip">图片img标签展示：</div><img src="'+this.result+'" alt=""/>';
            //alert($("#fileStr").val());
            $("#fileType").val(file.type);
            //alert(file.type);
            $("#showImageInfoImg").attr("src", this.result);
        }
    }

    var input1 = document.getElementById("image_file_input1");
    if (typeof(FileReader) === 'undefined') {
        alert("抱歉，你的浏览器不支持 FileReader，请使用现代浏览器操作！");
        input1.setAttribute('disabled', 'disabled');
    } else {
        input1.addEventListener('change', readFile1, false);
    }

    function readFile1() {

        var file = this.files[0];
        if(file == undefined) {
            //layer.msg("发送内容过大，请检查图片和内容");
            $("#showImageInfoImg1").attr("src",img64);
            $("#fileStr1").val("");
            $("#fileType1").val("");
            return;
        }
        //这里我们判断下类型如果不是图片就返回 去掉就可以上传任意文件
        if (!/image\/\w+/.test(file.type)) {
            layer.msg("请确保文件为图像类型");
            return false;
        }
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function (e) {
            $("#fileStr1").val(this.result);
            //document.getElementById("fileStr").value = '<img src="'+this.result+'" alt=""/>';
            //img_area.innerHTML = '<div class="sitetip">图片img标签展示：</div><img src="'+this.result+'" alt=""/>';
            //alert($("#fileStr").val());
            $("#fileType1").val(file.type);
            //alert(file.type);
            $("#showImageInfoImg1").attr("src", this.result);
        }
    }

    var reload = function () {
//        $(grid_selector).jqGrid('clearGridData');  //清空表格
        $(grid_selector).jqGrid('setGridParam',{
            url:"/ktPurchase/getSupplierListByPage",
            datatype:'json',
//                    postData:param,
            page:1
        }).trigger("reloadGrid"); //重新载入
    }

</script>
<script type="text/javascript">
    //it causes some flicker when reloading or navigating grid
    //it may be possible to have some custom formatter to do this as the grid is being created to prevent this
    //or go back to default browser checkbox styles for the grid
    function styleCheckbox(table) {
        /**
         $(table).find('input:checkbox').addClass('ace')
         .wrap('<label />')
         .after('<span class="lbl align-top" />')


         $('.ui-jqgrid-labels th[id*="_cb"]:first-child')
         .find('input.cbox[type=checkbox]').addClass('ace')
         .wrap('<label />').after('<span class="lbl align-top" />');
         */
    }


    //unlike navButtons icons, action icons in rows seem to be hard-coded
    //you can change them like this in here if you want
    function updateActionIcons(table) {
        /**
         var replacement =
         {
             'ui-ace-icon fa fa-pencil' : 'ace-icon fa fa-pencil blue',
             'ui-ace-icon fa fa-trash-o' : 'ace-icon fa fa-trash-o red',
             'ui-icon-disk' : 'ace-icon fa fa-check green',
             'ui-icon-cancel' : 'ace-icon fa fa-times red'
         };
         $(table).find('.ui-pg-div span.ui-icon').each(function(){
				var icon = $(this);
				var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
				if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
			})
         */
    }

    //replace icons with FontAwesome icons like above
    function updatePagerIcons(table) {
        var replacement =
            {
                'ui-icon-seek-first': 'ace-icon fa fa-angle-double-left bigger-140',
                'ui-icon-seek-prev': 'ace-icon fa fa-angle-left bigger-140',
                'ui-icon-seek-next': 'ace-icon fa fa-angle-right bigger-140',
                'ui-icon-seek-end': 'ace-icon fa fa-angle-double-right bigger-140'
            };
        $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function () {
            var icon = $(this);
            var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

            if ($class in replacement) icon.attr('class', 'ui-icon ' + replacement[$class]);
        })
    }

    function enableTooltips(table) {
        $('.navtable .ui-pg-button').tooltip({container: 'body'});
        $(table).find('.ui-pg-div').tooltip({container: 'body'});
    }
</script>
<!-- 模态框 -->
<script type="text/javascript">
    jQuery(function($){
        //解决模态框背景色越来越深的问题
        $(document).on('show.bs.modal', '.modal', function(event) {
            $(this).appendTo($('body'));
        }).on('shown.bs.modal', '.modal.in', function(event) {
            setModalsAndBackdropsOrder();
        }).on('hidden.bs.modal', '.modal', function(event) {
            setModalsAndBackdropsOrder();
        });

        function setModalsAndBackdropsOrder() {
            var modalZIndex = 1040;
            $('.modal.in').each(function(index) {
                var $modal = $(this);
                modalZIndex++;
                $modal.css('zIndex', modalZIndex);
                $modal.next('.modal-backdrop.in').addClass('hidden').css('zIndex', modalZIndex - 1);
            });
            $('.modal.in:visible:last').focus().next('.modal-backdrop.in').removeClass('hidden');
        }

        //覆盖Modal.prototype的hideModal方法
        $.fn.modal.Constructor.prototype.hideModal = function () {
            var that = this
            this.$element.hide()
            this.backdrop(function () {
                //判断当前页面所有的模态框都已经隐藏了之后body移除.modal-open，即body出现滚动条。
                /*<![CDATA[*/
                $('.modal.fade.in').length === 0 && that.$body.removeClass('modal-open')
                /*]]>*/
                that.resetAdjustments()
                that.resetScrollbar()
                that.$element.trigger('hidden.bs.modal')
            })
        }
    });
</script>
<!-- 模态框 -->
<script type="text/javascript">
    $("#editState").click(function () {
        var id = $(grid_selector).jqGrid('getGridParam', 'selrow');
        if (!id) {
            layer.msg("提示：请选择一条信息");
            return;
        }
        var rowData = $(grid_selector).jqGrid('getRowData', id);
        $('#example1').modal('show');
    });

    $("#saveState").click(function () {
        var id = $(grid_selector).jqGrid('getGridParam', 'selrow');
        var rowData = $(grid_selector).jqGrid('getRowData', id);

        queryModel.id = id;
        queryModel.state = $("#state1").val();
        getObjects()
        $('#example1').modal('hide');
    })
</script>
</body>
</html>